package ru.housewife.service.prices;

import org.hibernate.Session;
import ru.common.hibernate.HibernateAction;
import ru.housewife.form.WareUserPriceForm;
import ru.housewife.model.WareUserPrice;

/**
 * TODO: add description
 *
 * @author atroshanin
 */
public class UpdateWareUserPrice implements HibernateAction<Void> {

    private WareUserPriceForm userPriceForm;

    public UpdateWareUserPrice(WareUserPriceForm userPriceForm) {
        this.userPriceForm = userPriceForm;
    }

    @Override
    public Void execute(Session session) {
        WareUserPrice wareUserPrice = (WareUserPrice) session.get(WareUserPrice.class, userPriceForm.getId());
        wareUserPrice.setPrice(userPriceForm.getPrice());
        session.save(wareUserPrice);
        return null;
    }
}
